package com.letoken.platform.pub.exception;


import com.letoken.platform.pub.enums.ApiResponseCode;
import com.letoken.platform.pub.enums.ApiResponseEnum;

import java.math.BigDecimal;

/**
 * ApiServiceException
 *
 */
public class ApiServiceException extends RuntimeException {

    private int code = ApiResponseEnum.ERROR_001.getCode();
    private Object[] args = new Object[]{};


    private String desc;

    public ApiServiceException(String message) {
        super(message);
        this.desc = message;
    }

    public ApiServiceException(int code, String message) {
        super(message);
        this.code = code;
    }

    public ApiServiceException(int code, String message,String desc) {
        super(message);
        this.code = code;
        this.desc = desc;
    }


    public ApiServiceException(ApiResponseCode codeEnum, Object... args) {
        this(String.format(codeEnum.getMsg(), args));
        this.code = codeEnum.getCode();
        this.desc = codeEnum.getDesc();
        this.args = args;
    }



    public ApiServiceException(ApiResponseCode codeEnum, String msg) {
        this(msg);
        this.code = codeEnum.getCode();
    }

    public int getCode() {
        return this.code;
    }
    public String getDesc() {
        return this.desc;
    }

    public Object[] getArgs() {
        return args;
    }
}

